package rabbitmq.producer;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import rabbitmq.comm.Event;

@Component
public class Sender {

    private RabbitTemplate rabbitTemplate;

    @Autowired
    public Sender(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    public void send(Event event) {
        CorrelationData correlationData = new CorrelationData();
        correlationData.setId(event.getId());
        rabbitTemplate.convertAndSend("order-exchange", "order.abc", event, correlationData);
    }
}
